#!/usr/bin/env python
#-*- coding: utf-8 -*-
'''=========================
@Time : 2021/1/2 19:12
@Coder: xh
@IDE  : PyCharm
========================='''
import orm
import asyncio
from models import User, Blog, Comment

async def test(loop):
    await orm.create_pool(loop=loop, user='root', password='184ypsxh', db='moe')
                                                        #密码填自己的密码
    u = User(name='Test', email='test@qq.com', passwd='1234567890', image='about:blank')
    await u.save()
    #添加到数据库后需要关闭连接池，否则会报错
    orm.__pool.close()
    await orm.__pool.wait_closed()
if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(test(loop))
    loop.close()